var t = getApp();

Page({
    data: {
        language: "",
        info: {},
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        groupShareStatus: !1
    },
    onLoad: function(t) {
        "zhpGroup" == t.types ? this.setData({
            type: "zhpGroup"
        }) : "ywmGroup" == t.types && this.setData({
            type: "ywmGroup"
        }), this._getData();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore && this.getMoreData();
    },
    onShareAppMessage: function(a) {
        var e = wx.getStorageSync("yz_uid"), o = "";
        if (e && (o = e), a && "button" == a.from && "shareTag" == a.target.dataset.tag && "1" == a.target.dataset.item) {
            var r = "/packageB/member/group/GroupDetail/GroupDetail?id=" + a.target.dataset.info.id + "&mid=" + o, i = a.target.dataset.title;
            return a.target.dataset.store && (r = "/packageB/member/group/GroupDetail/GroupDetail?id=" + a.target.dataset.info.id + "store=" + a.target.dataset.store + "&mid=" + o), 
            1 == t.globalData.store_alone_temp && that.globalData.STORE_ID && (r = "".concat(r, "&store_alone_id=").concat(t.globalData.STORE_ID)), 
            "ywm" == this.data.type && (r = "".concat(r, "&plu=ywm")), console.log(r), {
                path: r,
                title: i
            };
        }
        return "zhpGroup" == this.data.type ? {
            title: "拼团列表",
            path: "/packageB/member/group/GroupList/GroupList?types=zhpGroup"
        } : 1 == t.globalData.store_alone_temp && that.globalData.STORE_ID ? {
            path: "/packageB/member/group/GroupList/GroupList?store_alone_id=".concat(t.globalData.STORE_ID)
        } : void 0;
    },
    _getData: function() {
        var a, e = this, o = {};
        "zhpGroup" == this.data.type ? (a = t.getNetAddresss("plugin.zhp-group-lottery.frontend.activity.get-activity-list"), 
        wx.setNavigationBarTitle({
            title: "拼团列表"
        })) : "ywmGroup" == this.data.type ? (a = t.getNetAddresss("plugin.ywm-fight-groups.frontend.controllers.fight-groups.index"), 
        this.options.id && (o.member_open_group_id = this.options.id)) : a = t.getNetAddresss("plugin.fight-groups.frontend.controllers.fight-groups.index"), 
        t._getNetWork({
            url: a,
            data: o,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    isLoadMore: !0,
                    total_page: a.data.last_page
                }), e.data.total_page || e.setData({
                    total_page: 0
                }), e.setData({
                    info: a.data.data
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var e, o = this.data.page;
            o += 1, this.setData({
                page: o
            }), "zhpGroup" == this.data.type ? e = t.getNetAddresss("plugin.zhp-group-lottery.frontend.activity.get-activity-list") : "ywmGroup" == this.data.type ? (e = t.getNetAddresss("plugin.ywm-fight-groups.frontend.controllers.fight-groups.index"), 
            this.options.id && (e += "&member_open_group_id=" + this.options.id)) : e = t.getNetAddresss("plugin.fight-groups.frontend.controllers.fight-groups.index"), 
            e += "&page=" + this.data.page, t._getNetWork({
                url: e,
                success: function(t) {
                    var e = t.data;
                    if (a.setData({
                        isLoadMore: !0
                    }), 1 == e.result) {
                        var o = e.data.data;
                        a.setData({
                            info: a.data.info.concat(o)
                        });
                    } else {
                        var r = a.data.page;
                        r--, a.setData({
                            page: r,
                            isLoadMore: !1
                        }), wx.showToast({
                            icon: "none",
                            title: e.msg,
                            duration: 1500
                        });
                    }
                }
            });
        }
    },
    orderGo: function(t) {
        "finance" != t.currentTarget.dataset.key ? wx.navigateTo({
            url: "/packageB/member/group/MyGroups/MyGroups?types=zhpGroup"
        }) : wx.navigateTo({
            url: "/packageI/newGroup/zhpFinance/zhpFinance"
        });
    },
    goGroup: function(t) {
        var a = "/packageA/detail_v2/detail_v2?id=" + (t.target.dataset.id || t.currentTarget.dataset.id);
        if ("zhpGroup" != this.data.type) {
            if ("ywmGroup" == this.data.type) return this.options.id && (a = a + "&cid=" + this.options.id), 
            void wx.navigateTo({
                url: a + "&name=ywmGroup"
            });
            var e = t.target.dataset.store_id || t.currentTarget.dataset.store_id;
            e ? wx.navigateTo({
                url: a + "/" + e + "&name=group"
            }) : wx.navigateTo({
                url: a + "&name=group"
            });
        } else wx.navigateTo({
            url: a + "&name=zhpGroup"
        });
    }
});